package trie;

import java.util.TreeMap;

public class ApproximateMatching implements Comparable<ApproximateMatching>{
	private int distance;
	private String word;
	private String matchingWord;
	
	/**
	 * liste des documents et des scores
	 */
	private TreeMap<String, Float> documents;
	
	public ApproximateMatching(String word, String matchingWord, int distance) {
		this.distance = distance;
		this.word = word;
		this.matchingWord = matchingWord;
		documents = new TreeMap<String, Float>();
	}


	public ApproximateMatching(String word, String matchingWord, int distance, TreeMap<String, Float> documents) {
		this.distance = distance;
		this.word = word;
		this.matchingWord = matchingWord;
		this.documents = documents;
	}

	
	/**
	 * @return the distance
	 */
	public int getDistance() {
		return distance;
	}

	/**
	 * @return the matchingWord
	 */
	public String getMatchingWord() {
		return this.matchingWord;
	}

	/**
	 * @return the word
	 */
	public String getWord() {
		return word;
	}
	
	@Override
	public String toString() {
		return this.word + "->" + this.matchingWord + "(" + this.distance + ")\t doc : "+documents;
	}

	@Override
	public int compareTo(ApproximateMatching o) {
		return new Integer(this.distance).compareTo(o.distance);
	}
	
	@Override
	public boolean equals(Object o) {
		if (o instanceof ApproximateMatching) {
			ApproximateMatching m = (ApproximateMatching)o;
			return (m.distance == this.distance && m.word.equals(this.word) && m.matchingWord.equals(this.matchingWord));
		} else {
			return false;
		}
	}


	public TreeMap<String, Float> getDocuments() {
		return documents;
	}

}
